﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;

namespace System.Web.Mvc
{
    public static class CRC
    {
        public static string Content(this System.Web.Mvc.UrlHelper Url, string Path, bool CRC)
        {
            if (!CRC)
                return Url.Content(Path);
            try
            {
                string serverPath = HttpContext.Current.Server.MapPath(Path);
                byte[] fileContents = File.ReadAllBytes(serverPath);
                string result =ElingOA6_DSJCJ.Common.CRC32.Compute(fileContents).ToString("X");
                return Url.Content(Path) + "?crc=" + result;
            }
            catch
            {
                return "";
            }
        }
    }

}